package myJs.api

import japgolly.scalajs.react.extra.Ajax
import myJs.myPkg.MyFetch
import upickle.default._
import org.scalajs.macrotaskexecutor.MacrotaskExecutor.Implicits._
import shared.pojo.Pojo.ValidData

/** Created by yz on 18/10/2022
  */
object MatrixFileDataApi {

  import shared.pojo.Pojo.matrixFileData._

  val baseUrl = s"${Api.apiUrl}/user/matrixFileData"

  def all(request: GetAll.Request) = {
    val url = s"${baseUrl}/all"
    Ajax
      .post(s"${url}")
      .setRequestContentTypeJson
      .send(write(request))
      .asAsyncCallback
      .map { xhr =>
        read[List[ujson.Obj]](xhr.responseText)
      }
  }

}
